<template>
	<view class="goods-list">
		<view v-if="type.includes('row')" class="goods-row flex">
			<router-link class="item" v-for="(item, index) in list" :key="index"
				:to="{path: '/pages/goods_details/goods_details', query: {id: item.goods_id || item.id}}">
				<view :class="[{'bg-white': showBg}]">
					<view class="goods-img">
						<u-image width="134rpx" height="190rpx" :src="item.image"></u-image>
					</view>
					<view class="goods-info">
						<view class="goods-name line-1 sm">{{item.name}}</view>
					</view>
				</view>
			</router-link>
		</view>

		<view v-if="type == 'hot'" class="goods-hot">
			<router-link v-for="(item, index) in list" :key="index"
				:to="{path: '/pages/goods_details/goods_details', query: {id: item.goods_id || item.id}}">
				<view class="item package flex bg-white m-t-20" v-if="item.is_container=='1'">
					<view class="package-info flex-1">
						<view class="goods-name line-2 m-b-10">{{item.name}}</view>
						<tips-icon type="presale" v-if="item.is_presale=='1'"></tips-icon>
						<tips-icon type="package" v-if="item.delivery_type.indexOf('4')>-1"></tips-icon>
					</view>
					<view class="package-image-box">
						<view style="display: flex;">
							<view class="package-image-list" v-for="(cell,idx) in item.container_goods_detail"
								:key="idx">
								<u-image width="105" height="140" :src="cell.image" v-if="idx<3"></u-image>
							</view>
						</view>
						<view>
							<text>共{{item.container_item.length}}件</text>
							<u-icon name="arrow-right"></u-icon>
						</view>
					</view>
					<view class="package-price-box">
						<text>组合价：</text>
						<price-format :color="colorConfig.primary" :first-size="34" :second-size="34"
							:subscript-size="26" :price="item.min_price"></price-format>
						<price-format :color="colorConfig.muted" v-if="item.min_price!=item.origin_min_price" :first-size="26" :second-size="26" :subscript-size="24" line-through :price="item.origin_min_price" style="margin-left: 10rpx;"></price-format>
					</view>
				</view>
				<view class="item flex bg-white m-t-20" v-else>
					<view class="goods-img">
						<u-image :lazy-load="true" width="140rpx" height="196rpx" :src="item.image" />
					</view>
					<view class="goods-info m-l-20 flex-1">
						<view class="goods-name line-2 m-b-10">{{item.name}}</view>
						<tips-icon type="presale" v-if="item.is_presale=='1'"></tips-icon>
						<tips-icon type="package" v-if="item.delivery_type.indexOf('4')>-1"></tips-icon>
						<view class="row-between flex m-t-10">
							<view class="price m-t-10 flex" style="align-items: flex-end;">
								<price-format :color="colorConfig.primary" class="m-r-10" :first-size="34"
									:second-size="34" :subscript-size="26" :price="item.min_price" :weight="500">
								</price-format>
								<price-format :color="colorConfig.muted" v-if="item.min_price!=item.origin_min_price" :first-size="26" :second-size="26" :subscript-size="26" line-through :price="item.origin_min_price" style="margin-left: 10rpx;"></price-format>
							</view>
						</view>
					</view>
				</view>
			</router-link>
		</view>
		<view v-if="type == 'activity'" class="goods-hot">
			<router-link v-for="(item, index) in list" :key="index"
				:to="{path: '/pages/goods_details/goods_details', query: {id: item.goods_id || item.id}}">
				<view class="item flex bg-white m-t-20">
					<view class="goods-img">
						<u-image :lazy-load="true" width="180rpx" height="180rpx" border-radius="6rpx"
							:src="item.image" />
					</view>
					<view class="goods-info m-l-20 flex-1">
						<view class="goods-name line-2 m-b-10">{{item.name}}</view>
						<text class="views br16 xxs">{{item.views}}浏览量</text>
						<view class="row-between flex m-t-10">
							<view class="price m-t-10 flex" style="align-items: flex-end;">
								<price-format :color="colorConfig.primary" class="m-r-10" :first-size="34"
									:second-size="26" :subscript-size="26" :price="item.price" :weight="500">
								</price-format>
								<price-format :color="colorConfig.muted" v-if="item.min_price!=item.market_price" class="muted" :firstSize="26" :secondSize="26" :subscript-size="24" line-through :price="item.market_price"></price-format>
							</view>
							<button class="bg-primary br16 white btn" size="xs">立即抢购</button>
						</view>
					</view>
				</view>
			</router-link>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			type: {
				type: String,
				default: 'double'
			},
			list: {
				type: Array,
				default: () => []
			},
			isBargain: {
				type: Boolean,
				default: false
			},
			// 两行时有效
			width: {
				type: String,
				default: '347rpx'
			},
			showBg: {
				type: Boolean,
				default: true
			},
		},
		data() {
			return {

			};
		}
	}
</script>

<style lang="scss" scoped>
	.goods-list {

		// 自营标签
		.store-tag::before {
			content: '自营';
			font-size: 22rpx;
			color: $-color-white;
			padding: 0 10rpx;
			background: linear-gradient(267deg, #FF2C3C 0%, #F52E99 100%);
			border-radius: 6rpx;
		}

		.goods-waterfall {
			.item {
				width: 347rpx;
				border-radius: 10rpx;

				.goods-info {
					padding: 10rpx;

				}
			}
		}

		.goods-double {
			.item {
				width: 347rpx;
				border-radius: 10rpx;

				.goods-info {
					padding: 10rpx;

					.goods-name {
						height: 80rpx;
						line-height: 40rpx;
					}

				}
			}
		}

		.goods-one .item {
			padding: 20rpx;

			&:not(:last-of-type) {
				margin-bottom: 20rpx;
			}
		}

		.goods-seckill .item {
			padding: 20rpx;
		}

		.goods-new .item {
			padding: 0 20rpx 20rpx;
			border-radius: 10rpx;
		}

		.goods-row {
			justify-content: space-between;

			.item {
				position: relative;
				width: 136rpx;
				margin-right: 44rpx;
				border-radius: 16rpx;

				&:last-child {
					margin-right: auto;
				}

				.goods-name {
					height: 60rpx;
					line-height: 60rpx;
					font-size: 22rpx;
				}
			}
		}

		.goods-hot {
			.item {
				position: relative;
				padding: 30rpx 20rpx;
				border-radius: 16rpx;

				.goods-name {
					font-size: 30rpx;
					font-family: fangsong;
					font-weight: 700;
					color: #32302f;
				}

				.goods-info {
					width: 450rpx;
					min-height: 203rpx;
					padding: 20rpx 0;
					display: flex;
					flex-direction: column;
					justify-content: space-between;

					.sale {
						padding: 4rpx 18rpx;
						color: #F79C0C;
						background-color: rgba(247, 156, 12, .1);
					}

					.views {
						padding: 4rpx 18rpx;
						color: #ff2c3c;
						background-color: rgba(237, 83, 73, .1);
					}
				}

				&.package {
					display: flex;
					flex-direction: column;
					align-items: flex-start;

					.package-info {
						display: flex;
						width: 100%;
						padding-right: 10rpx;
						justify-content: space-between;

						.goods-info {
							flex: 1;
						}
					}

					.package-image-box {
						display: flex;
						width: 100%;
						flex-direction: row;
						align-items: center;
						justify-content: space-between;

						.package-image-list {
							flex: 1;
							display: flex;
							margin-right: 20rpx;
						}
					}

					.package-price-box {
						margin-top: 10rpx;
						font-size: 22rpx;
						color: #605e5d;
					}
				}

			}
		}

		.goods-row,
		.goods-hot {
			.paixu {
				position: absolute;
				top: 0;
				left: 20rpx;
				width: 48rpx;
				height: 60rpx;
			}
		}

		.goods-img {
			box-shadow: -5rpx 5rpx 20rpx -4rpx #919191;
		}
	}
</style>